import { takeEvery, call, put, delay } from 'redux-saga/effects'
import axios from 'axios'

// takeEvery()   执行异步任务  
// delay  模拟延时 
// call  封装的请求方式
// put  put === store.dispatch

// https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata
function* rootSaga() {
    // takeEvery(标识, 要执行逻辑的函数)
    yield takeEvery("SAGA_ADD", numAdd)
}


function* numAdd() {
    const res = yield call(axios.get, 'https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata')
    yield put({ type: "INIT", list: res.data.message })
}

export default rootSaga